

***weights


gen age18to24 = 0
replace age18to24=1 if age1>=18 & age1<=24

gen age25to34 = 0
replace age25to34=1 if age1>=25 & age1<=34

gen age35to44 = 0
replace age35to44=1 if age1>=35 & age1<=44

gen age45to54 = 0
replace age45to54=1 if age1>=45 & age1<=54
	
gen age55to64 = 0
replace age55to64=1 if age1>=55 & age1<=64
	
gen age65over = 0
replace age65over=1 if age1>=65 & age1<100	

bysort Female: tab age18to24

bysort Female: tab age25to34
bysort Female: tab age35to44
bysort Female: tab age45to54
bysort Female: tab age55to64
bysort Female: tab age65over



gen Hispanic = 0
replace Hispanic = 1 if hispanic3 >=2 & hispanic3<=17 & hispanic3~=15

gen NotHispanic = 0
replace NotHispanic = 1 if hispanic3==1


tab Male

tab Female

gen Black = 0
replace Black = 1 if ethnicity4=="2"

gen White = 0
replace White = 1 if ethnicity4=="1"

gen Northeast = 0
replace Northeast=1 if region6==1

gen Midwest = 0
replace Midwest=1 if region6==2

gen South = 0
replace South=1 if region6==3

gen West = 0
replace West=1 if region6==4


gen University = 0
replace University = 1 if standard_education_v28>=6 & standard_education_v28<=8

gen NonUniversity = 0
replace NonUniversity = 1 if standard_education_v28>=1 & standard_education_v28<=5

****great p weights

*Proportions in population (quotas)
*Proportions in data
*pweight = PopProp/SampleProp





****try it for gender and age

gen wMFA=.
replace wMFA = 340775.510204082 if age18to24==1 & Male ==1
replace wMFA = 182166.666666667 if age18to24==1 & Female ==1

replace wMFA = 275144.578313253 if age25to34==1 & Male ==1
replace wMFA = 215836.538461538 if age25to34==1 & Female ==1

replace wMFA = 138760 if age35to44==1 & Male ==1
replace wMFA = 286351.351351351 if age35to44==1 & Female ==1

replace wMFA = 281507.246376812 if age45to54==1 & Male ==1
replace wMFA = 306893.939393939 if age45to54==1 & Female ==1

replace wMFA = 527184.210526316 if age55to64==1 & Male ==1
replace wMFA = 189078.260869565 if age55to64==1 & Female ==1
replace wMFA = 394046.875 if age65over==1 & Male ==1
replace wMFA = 225125 if age65over==1 & Female ==1

gen MFAstrat=.
replace MFAstrat = 1 if age18to24==1 & Male ==1
replace MFAstrat = 2 if age18to24==1 & Female ==1

replace MFAstrat = 3 if age25to34==1 & Male ==1
replace MFAstrat = 4 if age25to34==1 & Female ==1

replace MFAstrat = 5 if age35to44==1 & Male ==1
replace MFAstrat = 6 if age35to44==1 & Female ==1

replace MFAstrat = 7 if age45to54==1 & Male ==1
replace MFAstrat = 8 if age45to54==1 & Female ==1

replace MFAstrat = 9 if age55to64==1 & Male ==1
replace MFAstrat = 10 if age55to64==1 & Female ==1
replace MFAstrat = 11 if age65over==1 & Male ==1
replace MFAstrat = 12 if age65over==1 & Female ==1


svyset [pweight = wMFA],  strata(MFAstrat)












